<?php
namespace Admin\Controller;
use Think\Controller;
class AuthController extends Controller {
    public function login(){
        if(IS_POST){
            $name=I('post.name','');
            $password=I('post.password','');
            $res=M('user')->where(['name'=>$name,'password'=>$password,'status'=>1])->find();
            if($res){
                session('user_obj',$res);
                $this->success('登录成功',U('Index/index'));
            }else{
                $this->error('登录失败');
            }
        }else{
            $this->display('login');
        }
    }

    public function logout(){
        session('user_obj',null);
        $this->success('登出成功',U('Auth/login'));
    }

    
}